package src.lab03.test13;

import java.sql.*;

/**
 * Created by 阿阿阿阿豪丶 on 2017/12/15.
 */
public class Test {
    public static void main(String[] args) {
        //3+1
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;

        String sql = "insert into"+" t_students(id,real_name,age,gender,department,stu_no)"+" values(1,'chen',21,1,'信息与工程学院','10210240089')";


        try {
            Class.forName("com.mysql.cj.jdbc.Driver");

            connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/java_2017?serverTimezone=UTC",
                    "root",
                    "123456"
            );

            statement = connection.createStatement();

            //ResultSet：“查”

            statement.execute(sql);


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        finally {
            try {
                statement.close();
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

}
